home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / archiver / uudecode.doc < prev    next >
Text File  |  1995-04-22  |  10KB  |  176 lines

  1.  
  2.  
  3.  
  4.               U S E R   M A N U A L
  5.  
  6.                   f o r
  7.  
  8.            BASIC/Machine Language UUDECODER Version 1.2a
  9.                Manual Revision Date: 5/20/87
  10.  
  11.                 by John H. Sangster
  12.               jhs@mitre-bedford.arpa
  13.                (617) 235-8753 (home)
  14.                (617) 271-2000 (work)
  15.  
  16.  
  17.  
  18. 1.  PURPOSE:
  19.  
  20. Uudecode is the decoder for uuencode, a program widely used on unix systems to
  21. encode binary files into printing ASCII characters for transmission over
  22. networks.  Because many network components interpret and respond to special
  23. "control" characters, attempts to send binary files such as machine-language
  24. programs over a network in raw, un-encoded form are usually doomed to failure.
  25. Uuencode has become popular for encoding because it is fairly efficient:
  26. it encodes each group of three 8-bit bytes into only four bytes of printable
  27. characters.  Therefore, using uuencode, a file is expanded by a factor of only
  28. 1.333 to one as the price of constraining the character set to be limited to
  29. printing characters only.
  30.  
  31.  
  32. 2.  USING UUDECODE VER. 1.2a:
  33.  
  34. UUDECODE VER. 1.2a is normally sent by e-mail as an Atari BASIC ".LST" file.
  35. This means that it consists of only printing characters itself, and can be
  36. mailed, printed, etc. without difficulty.  On the other hand, the first time
  37. you run it, you will have to "ENTER" it into BASIC with a command like
  38. 'ENTER "D:UUDECODE.LST"<RETURN>'.  Then you should SAVE it with the command
  39. 'SAVE "D:UUDECODE.BAS"<RETURN>'.  Thereafter, you can run it under BASIC with
  40. the RUN command instead of the ENTER command. You will immediately notice that
  41. RUN works significantly faster.  This is true because SAVED files are in
  42. tokenized form.  You can delete the .LST file if you wish, because it can
  43. always be reconstructed using the LIST command, but you should be sure to keep
  44. a backup copy of UUDECODE in some form on a separate disk from the one you
  45. normally run it from.  Keeping the .LST file around is handy if you decide to
  46. e-mail it to someone else someday.
  47.  
  48. Once you have UUDECODE running, it will ask you for the input file you wish to
  49. uudecode and the filename you want the output to be sent to.  You should give
  50. it the exact input file specification you want it to use, i.e. including
  51. device, filename, and extension.  Normally, uuencoded files are given the
  52. extenion ".UUE", but you will have to tell the program that.  On the output
  53. file specification, however, the program will accept either a null input
  54. (just a <RETURN>) or a device specifier like D1: without a filename, or you
  55. can again specify the full filename and extension.  In the first two cases, it
  56. will attempt to read the filename from the "begin" line of the uuencoded input
  57. file.  If you don't even specify a device name, it will assume "D1:" and will
  58. so inform you.  If it cannot successfully OPEN the file it thinks you want,
  59. it will give you another chance to enter the output filename.  Before it gets
  60. to this point, however, it will have printed the "begin" line if one was
  61. found, so you may have a clue as to what went wrong, e.g. a filename was given
  62. which is not valid for your DOS.  In that case, you should think up a valid
  63. filename that seems suitable.
  64.  
  65. After finishing a file, UUDECODE will print "Done!" and will ask if you want
  66. to decode another file.  If you say "Y" or "yes", it will re-initialize and
  67. allow you to enter the new input and output filenames.  Otherwise, it will
  68. exit to DOS.  NOTE:  UUDECODE Ver. 1.2a also prints a byte count when it
  69. finishes.  You should note this count and compare it with the correct byte
  70. count as established when the file was being uuencoded.
  71.  
  72. That's about all there is to it.  Comments on this manual, as well as on any
  73. difficulties experienced with UUDECODE, should be directed to the author.
  74.  
  75.  
  76. 3.  WHAT UUENCODE AND UUDECODE REALLY DO TO THE DATA:
  77.  
  78. The uuencoding process, used to create ASCII files of the type that UUDECODE
  79. is designed to decode, is easy to describe.  Each group of three input bytes,
  80. with any 8-bit pattern whatever in them, is broken up into four sets of six
  81. bits.  (Note that three times 8 and four times 6 each give exactly 24 bits, so
  82. no information is lost.)  Each 6-bit pattern is put in the low-order 6 bits of
  83. an 8-bit byte, and decimal 32 is added to give a final value in the range 32
  84. (ASCII blank) through 95.  All the characters in this range (decimal 32
  85. through 95) are printing characters.
  86.  
  87. Traditionally, uuencode programs take 45 bytes at a time from the input file
  88. as long as bytes are available, and encode them into 60 output bytes which are
  89. sent as one "line".  Each line is made up as an encoded byte count, the 60
  90. encoded bytes of data, and an end-of-line character or characters.  The
  91. encoded byte count is the actual number of input bytes encoded on that line,
  92. plus decimal 32.  For all lines but the last, this gives 45 plus 32, or 77,
  93. which translates into ASCII uppercase "M".  That is why all lines but the last
  94. in a uuencoded file begin with "M".  The final line of data begins with a
  95. character which is between "blank" (32) and "M" (77) in the ASCII "collating
  96. sequence".  The exact value depends on how many bytes were left in the input
  97. file after the last full line of 45 was used up.
  98.  
  99. Uuencode programs usually sandwich these lines of data between a "begin" line
  100. and an "end" sequence.  The "begin" line consists of the word "begin", a
  101. single space, a 3-digit "protection code" as used by unix systems, another
  102. single space, and finally the filename which should be used for the file into
  103. which the data is decoded at the far end.  The "end" sequence is supposed to
  104. consist of a line containing a blank in the first character position, denoting
  105. zero encoded bytes on that line, followed by a line beginning with the word
  106. "end".  Some unix-based uudecoders seem to require additional blanks following
  107. these minimum fields.
  108.  
  109. Uudecode is supposed to be the exact inverse of uuencode, i.e. after decoding
  110. a uuencoded file, you should have the exact binary file that was originally
  111. encoded.  This is essential, because the whole purpose of uuencode and
  112. uudecode is to let you transmit machine language object programs around on
  113. networks.  If even one bit is changed, all bets are off!  The basic idea of
  114. uudecode is therefore to take each line in, subtract 32 from each of the 60 or
  115. fewer bytes, pack each group of 6 bits in the low-order portion of each byte
  116. back into 8-bit packed binary form, and write the re-packed bytes out to a
  117. binary output file.
  118.  
  119.  
  120. 4.  PITFALLS:
  121.  
  122. Unfortunately, as uuencode has been adopted wholesale for use in transmitting
  123. binary files across networks, it has turned out that not all network hosts are
  124. as careful what they do with files as are most unix hosts.  IBM hosts are
  125. among the most notoriously callous about changing byte values to suit their
  126. own preconceived notions.  Most of the time, the changes consist of things
  127. like stripping off trailing blanks on lines that happen to end in a blank.
  128. This can be embarrassing if not handled properly by the decoder.  Another
  129. favorite trick is to change carat into accent grave, or tilde into carat, or
  130. what-have-you.  The only reliable way to handle this sort of problem seems to
  131. be for the uuencode program to send an encoding translation table at the
  132. beginning, which lists all the output characters from decimal 32 to 95, and
  133. for the uudecode program to capture the values received in their place and
  134. decode accordingly.  If they have not been mapped one-to-one, of course it can
  135. only throw up its hands in dismay and so inform you.
  136.  
  137.  
  138. 5.  CAPABILITIES OF UUDECODE VER. 1.2a:
  139.  
  140. UUDECODE Ver. 1.2a as described by this manual includes masking to correct the
  141. most common character translation problems, i.e. those which result in encoded
  142. values greater than 95.  It correctly decodes files in which a "sentinel"
  143. character (usually "a" or "x") has been added to the end of the uuencoded
  144. lines to prevent stripping of trailing blanks, as well as files in which
  145. trailing blanks have actually been stripped!  It does NOT process the
  146. "translation table" preamble added by some uuencodes; this may be added in a
  147. future revision.
  148.  
  149. This version also is capable of reading the output filename from the uuencoded
  150. file.  This will be done if you